package com.wmeimob.fastboot.jiubei.controller;

import com.github.pagehelper.PageInfo;
import com.wmeimob.fastboot.core.context.PageContext;
import com.wmeimob.fastboot.jiubei.service.ShopGoodsClickRecordService;
import com.wmeimob.fastboot.jiubei.entity.ShopGoodsClickRecord;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author wjt
 * @version 1.0
 * @className ShopGoodsClickRecordController
 * @description 【商品点击记录表】控制器
 * @date Mon Sep 07 23:58:44 CST 2020
 **/
@RestController
@RequestMapping("shopGoodsClickRecord")
@Slf4j
public class ShopGoodsClickRecordController {

    @Resource
    private ShopGoodsClickRecordService shopGoodsClickRecordService;


    /**
     * 商品点击记录表分页查询
     *
     * @param shopGoodsClickRecord
     * @return
     */
    @GetMapping
    public PageInfo queryForShopGoodsClickRecord(ShopGoodsClickRecord shopGoodsClickRecord) {
        PageContext.startPage();
        return new PageInfo<ShopGoodsClickRecord>(shopGoodsClickRecordService.list(shopGoodsClickRecord));

    }

    /**
     * 商品点击记录表导出
     *
     * @param shopGoodsClickRecord
     * @return
     */
    @PostMapping("/export")
    public List<ShopGoodsClickRecord> queryForShopGoodsClickRecordExport(@RequestBody ShopGoodsClickRecord shopGoodsClickRecord) {
        return shopGoodsClickRecordService.list(shopGoodsClickRecord);
    }


    /**
     * 商品点击记录表查询-<通过id查询>
     *
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    public ShopGoodsClickRecord queryForShopGoodsClickRecordById(@PathVariable("id") Object id) {
        return shopGoodsClickRecordService.queryShopGoodsClickRecordById(id);
    }


    /**
     * 商品点击记录表添加
     *
     * @param shopGoodsClickRecord
     * @return
     */
    @PostMapping
    public void insertForShopGoodsClickRecord(@RequestBody ShopGoodsClickRecord shopGoodsClickRecord) {
        shopGoodsClickRecordService.addShopGoodsClickRecord(shopGoodsClickRecord);
    }


    /**
     * 商品点击记录表修改
     *
     * @param shopGoodsClickRecord
     * @return
     */
    @PutMapping
    public void updateForShopGoodsClickRecord(@RequestBody ShopGoodsClickRecord shopGoodsClickRecord) {
        shopGoodsClickRecordService.modifyShopGoodsClickRecord(shopGoodsClickRecord);
    }

    /**
     * 商品点击记录表删除
     *
     * @param id
     * @return
     */
    @DeleteMapping("/{id}")
    public void removeForShopGoodsClickRecord(@PathVariable("id") String id) {
        shopGoodsClickRecordService.removeShopGoodsClickRecord(id);
    }
}
